package com.xnyzc.lhy.mis.controller.cmsapi.order;

import com.alibaba.fastjson.JSON;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.mis.entity.order.CharteredDetailsParam;
import com.xnyzc.lhy.mis.entity.order.OaCOrderPersonal;
import com.xnyzc.lhy.mis.entity.param.cms.order.CmsOadOrderPersonalParam;
import com.xnyzc.lhy.mis.entity.result.order.OrderList;
import com.xnyzc.lhy.mis.service.cms.order.ICmsOacOrderPersonalService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 自费叫车订单管理
 * @Author wangshuo
 * @Date 2019/10/17 16:31
 **/
@RestController
@RequestMapping(value = "cms/corder/personal")
public class CmsOacOrderPersonalController {

    @Autowired
    private ICmsOacOrderPersonalService iCmsOacOrderPersonalService;


    /**
     * 导出包车订单列表
     *
     * @param orderList
     * @return
     */
    @PostMapping(value = "/exportCharterOrderExcel")
    public Rv exportExcelOfCharterOrder(@RequestBody OrderList orderList) {
        return iCmsOacOrderPersonalService.exportExcelOfCharterOrder(orderList);
    }

    /**
     * 包车所有订单完成
     * @return
     */
    @PostMapping(value = "dealAllCharteredEnd")
    public Rv dealAllCharteredEnd(@ApiParam(name = "orderNo",value = "订单编号")String orderNo){
        return Rv.wrap();
    }

   @PostMapping(value = "getOrderDriverDetail")
   public Rv getOrderDriverDetail(@RequestBody(required = false) OrderList orderList){
       if(CheckUtil.objIsNotEmpty(orderList)){
           return iCmsOacOrderPersonalService.getCmsOaSysOrdersList(orderList.getDriverIds());
       }
       return Rv.wrap();
   }
    /**
     * 根据司机id获取订单列表
     *
     * @param: * @param target
     * @return:{@link com.xnyzc.lhy.common.entity.Rv}
     * @author:immor
     * @date:2021/4/28
     */
    @PostMapping(value = "getCmsOrderListByDriverId")
    public Rv getCmsOrderListByDriverId(@RequestParam("target") String target) {
        return iCmsOacOrderPersonalService.getCmsOrderListByDriverId(target);
    }

    /**
     * 获取自费叫车订单列表
     *
     * @return
     */
    @PostMapping(value = "getCmsOacOrderPersonalList")
    public Rv getCmsOacOrderPersonalList(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.getCmsOacOrderPersonalList(cmsOadOrderPersonalParam);
    }

    /**
     * 获取自费叫车订单详情
     *
     * @return
     */
    @PostMapping(value = "getCmsOacOrderPersonalDetail")
    public Rv getCmsOacOrderPersonalDetail(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.getCmsOacOrderPersonalDetail(cmsOadOrderPersonalParam);
    }

    /**
     * 获取包车订单详情
     *
     * @return
     */
    @PostMapping(value = "getOaDCharterOrderDetail")
    public Rv getOaDCharterOrderDetail(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.getOaDCharterOrderDetail(cmsOadOrderPersonalParam);
    }

    /**
     * 获取订单详细信息
     *
     * @return
     */
    @PostMapping(value = "getOrderDetail")
    public Rv getOrderDetail(@RequestParam("orderNo") String orderNo) {
        return iCmsOacOrderPersonalService.getOrderDetail(orderNo);
    }

    /**
     * 导出订单
     *
     * @return
     */
    @PostMapping(value = "exportOrderExcel")
    public Rv exportOrderExcel(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.exportOrderExcel(cmsOadOrderPersonalParam);
    }

    /**
     * 获取订单状态列表
     *
     * @return
     */
    @PostMapping(value = "getCmsOrderStatusList")
    public Rv getCmsOrderStatusList(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.getCmsOrderStatusList(cmsOadOrderPersonalParam);
    }

    /**
     * 车辆轨迹
     *
     * @return
     */
    @PostMapping(value = "ownexpenseTrajectory")
    public Rv ownexpenseTrajectory(@RequestParam("orderNo") String orderNo) {
        return iCmsOacOrderPersonalService.ownexpenseTrajectory(orderNo);
    }

    @GetMapping(value = "getOrderPersonalId")
    public Rv getOrderPersonalId(String orderId) {
        return iCmsOacOrderPersonalService.getOrderPersonalId(orderId);
    }

    /**
     * 新的订单列表
     *
     * @return
     */
    @PostMapping(value = "/getNewCharterOrderList")
    public Rv getNewCharterOrderList() {
        return iCmsOacOrderPersonalService.getNewCharterOrderList();
    }

    @PostMapping(value = "/getNewOrderList")
    public Rv getNewOrderList(@RequestBody OrderList orderList) {
        return iCmsOacOrderPersonalService.getNewOrderList(orderList);
    }

    /**
     * 退回携程
     * @param orderNo
     * @return
     */
    @PostMapping(value = "/cancelXCOrder")
    public Rv cancelXCOrder(@RequestParam String orderNo) {
        return iCmsOacOrderPersonalService.cancelXCOrder(orderNo);
    }

    /**
     * 只针对携程 更新最晚需要请求司机信息
     *
     * @return
     */
    @PostMapping(value = "/updateXCLastPushDriverTime")
    public Rv updateXCLastPushDriverTime() {
        return iCmsOacOrderPersonalService.updateXCLastPushDriverTime();
    }

    /**
     * 新的导出订单列表
     *
     * @param orderList
     * @return
     */
    @PostMapping(value = "/getNewExportOrderExcel")
    public Rv getNewExportOrderExcel(@RequestBody OrderList orderList) {
        return iCmsOacOrderPersonalService.getNewExportOrderExcel(orderList);
    }

    /**
     * 订单详情获取行程录音
     *
     * @return
     */
    @PostMapping(value = "getCmsOrderDetailRecording")
    public Rv getCmsOrderDetailRecording(@RequestBody CmsOadOrderPersonalParam cmsOadOrderPersonalParam) {
        return iCmsOacOrderPersonalService.getCmsOrderDetailRecording(cmsOadOrderPersonalParam);
    }

    /**
     * 自有订单新增
     * @param oaCOrderPersonal
     * @return
     */
    @PostMapping(value="/addNewOrder")
    public Rv addNewOrder(@RequestBody OaCOrderPersonal oaCOrderPersonal){
        return iCmsOacOrderPersonalService.addNewOrder(oaCOrderPersonal);
    }
    @PostMapping(value="/cancleOrder")
    public Rv cancleOrder(@RequestParam String orderNo){
        return iCmsOacOrderPersonalService.cancleOrder(orderNo);
    }

}
